Home
Ray
Articles
This Old House
Family History
Try Catch Throw
Enter a password
(8 - 12 characters, at least 1 number, no spaces)
SAMPLE CODE
Enter a password
(8 - 12 characters, at least 1 number, no spaces)
function checkPassword() { try{ var varPass = document.getElementById("f1").value; if (varPass.length < 8) { throw "Please enter at least 8 characters."; } if (varPass.indexOf(" ") !== -1) { throw "No spaces in the password, please."; } } // end try catch(err) { alert(err); } // end catch }